package com.sitaoke.stocks.dao;
import java.util.List;
import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Component;
import com.sitaoke.stocks.pojo.Stock;
import com.sitaoke.stocks.vo.EUIPager;

@Component
public class StockDao {
	
	@Autowired
	private JdbcTemplate jdbcTemplate;

	public Long getTotalCount(Map<String, Object> param) {
		String sql="SELECT COUNT(1) FROM t_stock T WHERE 1=1 \n"+getParamSql(param);
		return  jdbcTemplate.queryForObject(sql,Long.class);
	}

	public List<?> getPagerList(EUIPager ePager, Map<String, Object> param) {
		String  querySql="SELECT * FROM t_stock T WHERE 1=1\n"+getParamSql(param)+"\n ORDER BY T.DISPLAY_ORDER ASC";
		String sql="SELECT * FROM ("+querySql+")S limit ?,?";
		List<Stock> list = jdbcTemplate.query(sql,new Object[]{ePager.getStart(),ePager.getRows()},new BeanPropertyRowMapper(Stock.class));
		return list;
	}

	private String getParamSql(Map<String, Object> param) {
		return "";
	}

}
